module.exports  = function(success,error){
    const mongoose = require('mongoose');
    const {DBHOST,DBPORT,DBNAME} = require('../config/config');
mongoose.set('strictQuery',true);

console.log( DBHOST );
console.log( DBPORT);
console.log( DBNAME );
console.log( `mongodb://${DBHOST}:${DBPORT}/${DBNAME}` );

mongoose.connect(`mongodb://${DBHOST}:${DBPORT}/${DBNAME}`);

mongoose.connection.once('open',()=>{
    success();
});
mongoose.connection.on('error',()=>{
    error();
    console.log('连接失败');
});
mongoose.connection.on('close',()=>{
    console.log('连接关闭');
});

// setTimeout(() => {
//     mongoose.disconnect();
// }, 3000);
};